﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ColorMixer
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Pseudocode for "Primary color mixer"
             * Display "This program will provideyou with the color output when you mix 2 of the primary colors, red, blue and yellow
             * method getColors()
             * Display "Please provide the 2 colors to mix, Example: blue red, or red yellow, or yellow blue"
             * method getMixColor()
             * Display result or error message
             * Ask the user to mix 2 more colors or end the program
             * END THE PROGRAM
             */
            string color1 = "", color2 = "", colorMix = "", loop = "Y";
            print("This program will provide you with the color output when you mix 2 of the primary colors, red, blue and yellow.");
            while (loop.ToUpper() == "Y")
            {
                getColors(ref color1, ref color2);
                getMixColor(ref colorMix, color1, color2);
                print("If you would like to combine 2 different primary colors type \"Y\" or anything else to end the program");
                loop = Console.ReadLine();
            }
        }
        static void getMixColor(ref string colorMix, string color1, string color2)
        {
            if (color1 == "BLUE")
            {
                if (color2 == "YELLOW")
                {
                    print("This convination creates a GREEN color");
                }
                else if (color2 == "RED")
                {
                    print("This convination creates a PURPLE color");
                }
                else print("Invalid convination of colors, valid convinations: blue red, or red yellow, or yellow blue");
            }
            else if (color1 == "YELLOW")
            {
                if (color2 == "BLUE")
                {
                    print("This convination creates a GREEN color");
                }
                else if (color2 == "RED")
                {
                    print("This convination creates a ORANGE color");
                }
                else print("Invalid convination of colors, valid convinations: blue red, or red yellow, or yellow blue");
            }
            else if (color1 == "RED")
            {
                if (color2 == "YELLOW")
                {
                    print("This convination creates a ORANGE color");
                }
                else if (color2 == "BLUE")
                {
                    print("This convination creates a PURPLE color");
                }
                else print("Invalid convination of colors, valid convinations: blue red, or red yellow, or yellow blue");
            }
            else print("Invalid convination of colors, valid convinations: blue red, or red yellow, or yellow blue");
        }
        static void getColors(ref string color1, ref string color2)
        {
            print("Please provide the 2 colors to mix. Example: blue red, or red ywllow, or yellow blue.");
            char tok = ' ';
            string colors = Console.ReadLine();
            while (!colors.Contains(tok))
            {
                print("Invalid answer, Please provide the 2 colors to mix. Example: blue red, or red yellow, or yellow blue.");
                colors = Console.ReadLine();            
            }
            string[] splitColors = colors.Split(tok);
            color1 = splitColors[0].ToUpper();
            color2 = splitColors[1].ToUpper();
        }
        static void print(string t)
        {
            Console.WriteLine("\n{0}",t);
        }
    }
}
